import theme from './theme';
import * as echarts from 'echarts/src/echarts';
import 'echarts/src/chart/line';
import 'echarts/src/component/tooltip';
// import 'echarts/src/component/title';
import 'echarts/src/component/legend';
import 'zrender/src/svg/svg';
/**
 * @module common/echarts/line
 * @author ashen
 * @description  饼图，调用initLine方法初始化chart
 * @requires module:common/echarts/theme
 */

/**
 * @param  {Integer} id - 页面id或者class
 * @returns {Object} 图表实例dcChart
 */
export function initLine (id) {
  const dcChart = echarts.init(document.querySelector(id), theme, {renderer: 'svg'});
  dcChart.showLoading();
  dcChart.setOption(option);
  window.addEventListener('resize', function () {
    dcChart.resize();
  });
  return dcChart;
};
/** 导出图表配置option*/
export const option = {
  tooltip: {
    trigger: 'axis'
  },
  grid: {
    left: '5%',
    right: '5%',
    bottom: '16%',
    top: '10%',
    containLabel: true
  },
  legend: {
    bottom: '1%',
    center: 'center',
    height: '10%',
    data: []
  },
  toolbox: {
    feature: {
      saveAsImage: {}
    }
  },
  xAxis: {
    type: 'category',
    boundaryGap: false,
    data: []
  },
  yAxis: {
    type: 'value'
  },
  series: []
};
